<%@ page contentType="text/html;charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta charset="UTF-8">
<title>Table</title>

<link rel="stylesheet"
	href="<%=request.getContextPath()%>/js/layui-v1.0.9_rls/layui/css/layui.css"
	media="all" />
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/js/layui-v1.0.9_rls/layui/css/global.css"
	media="all">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/js/plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/js/layui-v1.0.9_rls/layui/css/table.css" />

<link rel="stylesheet" href="<%=request.getContextPath()%>/css/file.css"
	media="all" />
	
<link rel="stylesheet" href="<%=request.getContextPath()%>/resources/tab/css/style.css"
	media="all" />
	
	

<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/layui-v1.0.9_rls/layui/layui.js"></script>

<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jquery-1.8.0.min.js"></script>

<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/util.js"></script>


<script type="text/javascript">
		
	$(document).ready(function(){
		util.adjustDivHeight(600,"_contentDiv",10,38);
		util.tabs();
		
		
			layui.use([ 'upload', 'form', 'laydate','layer'], function() {
	
	
	
		layer = layui.layer;
	
		form = layui.form();
		
		
		
		//监听提交
		form.on('submit(saveBtn)', function(data) {
		
			var reqNo = $("#reqNo").val();
			//获取参数
			
			
			$.post("<%=request.getContextPath()%>/rms/createRmReqInfo",
			
					{"reqInfo.reqNo":reqNo,"reqInfo.reqName":data.field.reqName,"reqInfo.requiredTime":data.field.requiredTime,"reqInfo.reqDesc":data.field.reqDesc,"reqInfo.reqType":data.field.reqType},
					
				function(data){
			
					if(data.retCode == "0"){
					 	var reqNo = data.reqInfo.reqNo;
						util.showDialog("新建需求成功！",2,"retT=createCallBack('"+reqNo+"')");
					}else{
						util.showDialog("新建需求异常，请联系管理员！",0);
					}
			},"json");
			

			return false;
		});

		var upload = layui.upload;
		//上传文件
		layui.upload({
							url : '<%=request.getContextPath()%>/rms/uploadAttach?reqInfo.reqNo=<s:property value="reqInfo.reqNo"/>'
									,
									title : '上传文件',
									ext : 'jpg|png|gif|rar|doc|docx|xls|xlsx|zip',
									method : 'post' //上传接口的http类型
									//上传前
									,
									before : function(input) {

										//返回的参数item，即为当前的input DOM对象
										//console.log('文件上传中');
									},
									success : function(res) {

										var fileName = decodeURI(res.fileName);
										var saveName = res.saveName;
										var fileStr = '<div class="layui-form-item"><div class="layui-inline "><a href="javascript:void(0)" onclick=util.downloadFile("<%=request.getContextPath()%>/rms/downloadFile","'+saveName+'","'+fileName+'")>'+fileName+'</a></div></div><a href="javascript:void(0)" data-id="1" data-opt="del" class="layui-btn layui-btn-danger layui-btn-mini">删除</a>';
										//alert(fileStr);
										$("#attachFileDiv").append(fileStr);

										//alert(res.retCode);
										//console.log(res); //如：{"code":0 ,"msg":"","url":"http://cdn.abc.com/123.jpg"'} 
										//alert(res.url);
									}
								});

				
						//reqTimeObj.laydate();
						//laydate.laydate({"elem: 'reqTime',format: 'YYYY-MM-DD hh:mm:ss'"});

					});
		
	});	
	
	function createCallBack(reqNo){
	
		
		parent._addTab("我的需求", "<%=request.getContextPath()%>/rms/myReqList?reqInfo.reqNo="+reqNo);
		parent._closeTab("发起需求");
	}
	


	//反馈按钮处理
	function cancel() {

		parent._closeTab("测试");
	}

	function addTabTest() {
		parent._addTab("测试2", "http://www.sina.com.cn");
	}

	//下载附件
	function downLoadFile(saveName) {
		alert(saveName);
	}
</script>
</head>
<body style="background: white">
	
	<div class="tabox">
	      <div class="hd">
	        <ul>
	          <li class="on" id="tab-0">基本信息</li>
	          <li class=" "  id="tab-1">处理轨迹</li>
	          <li class=""   id="tab-2">需求附件</li>
	         </ul>
	      </div>
	 </div>
		    
	<div id="_contentDiv">
	
		 <div id="content-0">
				
				<form class="layui-form">
					<s:hidden name="reqInfo.reqNo" id="reqNo"></s:hidden>
		
					<div class="layui-form-item">
						<label class="layui-form-label">需求名称</label>
						<div class="layui-input-block">
							<input type="text" lay-verify="required" id="reqName"
								name="reqName" placeholder="需求名称" autocomplete="off"
								class="layui-input" value="<s:property value='reqInfo.reqName'/>" readonly>
						</div>
					</div>
		
					<div class="layui-form-item">
						<label class="layui-form-label">需求分类</label>
							<div class="layui-input-inline">
									<select name="modules" lay-verify="required" lay-search="" disabled>
										<option value=""></option>
										<s:iterator value="reqTypeList" id="reqTypeInfo">
											<!-- 不能将option换行 -->
											<option value="<s:property value='#reqTypeInfo.reqType' />" <s:property value='#reqTypeInfo.chooseFlag' />><s:property value='#reqTypeInfo.reqTypeDesc' /></option>
										</s:iterator>
						
									</select>
								</div>
		
					</div>
					
					
					<div class="layui-form-item layui-form-text">
						<label class="layui-form-label">需求描述</label>
						<div class="layui-input-block">
							<textarea lay-verify="required" id="reqDesc" name="reqDesc"
								placeholder="需求描述" class="layui-textarea" readonly> <s:property value="reqInfo.reqDesc"/></textarea>
						</div>
					</div>
		
					<div class="layui-form-item">
						<label class="layui-form-label">提出人</label>
		
						<div class="layui-input-inline">
							<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
								placeholder="要求完成时间" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.createName"/>' readonly>
						</div>
						
						<label class="layui-form-label">提出时间</label>
		
						<div class="layui-input-inline">
							<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
								placeholder="要求完成时间" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.createTime"/>' readonly>
						</div>
		
					</div>
					
					<div class="layui-form-item">
							<label class="layui-form-label">要求完成时间</label>
		
							<div class="layui-input-inline">
								<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
									placeholder="要求完成时间" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.requiredTime"/>' readonly>
							</div>
							<label class="layui-form-label">厂家责任人</label>
		
							<div class="layui-input-inline">
								<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
									placeholder="" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.serviceName"/>' readonly>
							</div>
					</div>
					<div class="layui-form-item">
							<label class="layui-form-label">厂家确认完成时间</label>
		
							<div class="layui-input-inline">
								<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
									placeholder="要求完成时间" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.serviceTime"/>' readonly>
							</div>
							<label class="layui-form-label">实际完成时间</label>
		
							<div class="layui-input-inline">
								<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
									placeholder="" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.finishTime"/>' readonly>
							</div>
					</div>
					
					<div class="layui-form-item">
							<label class="layui-form-label">是否按时完成</label>
		
							<div class="layui-input-inline">
								<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
									placeholder="" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.timeFlag"/>' readonly>
							</div>
							<label class="layui-form-label">是否超期</label>
		
							<div class="layui-input-inline">
								<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
									placeholder="" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.overFlag"/>' readonly>
							</div>
					</div>
					<div class="layui-form-item">
							<label class="layui-form-label">确认可超期天数</label>
		
							<div class="layui-input-inline">
								<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
									placeholder="" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.permitDay"/>' readonly>
							</div>
							<label class="layui-form-label">实际超期天数</label>
		
							<div class="layui-input-inline">
								<input type="text" name="requiredTime" id="requiredTime" lay-verify="time"
									placeholder="" autocomplete="off" class="layui-input" value='<s:property value="reqInfo.overDay"/>' readonly>
							</div>
					</div>
		
		
					<div class="layui-form-item layui-form-text">
						<label class="layui-form-label">完成情况</label>
						<div class="layui-input-block">
							<textarea lay-verify="required" id="reqDesc" name="reqDesc"
								placeholder="需求描述" class="layui-textarea" readonly> <s:property value="reqInfo.finishDesc"/></textarea>
						</div>
					</div>
		
				
		
		
		
				</form>
				 	
		 </div>
		 
		 <div id="content-1" style="display:none">
		 
 	 		<div class="layui-field-box layui-form">
				<table class="layui-table admin-table">
					<thead>
						<tr>
							<th>任务名称</th>
							<th>派发时间</th>
							<th>状态</th>
							<th>处理人</th>
							<th>处理时间</th>
							<th>处理方式</th>
							<th>处理备注</th>
						</tr>
					</thead>
					<tbody id="content">
						<s:iterator value="taskList" id="taskInfo">
							<!-- 不能将option换行 -->
							<tr>
								<td><s:property value="#taskInfo.taskName"/></td>
								<td><s:property value="#taskInfo.createTime"/></td>
								<td><s:property value="#taskInfo.sts"/></td>
								<td><s:property value="#taskInfo.opName"/></td>
								<td><s:property value="#taskInfo.opTime"/></td>
								<td><s:property value="#taskInfo.dealType"/></td>
								<td><s:property value="#taskInfo.opDesc"/></td>
							</tr>
						</s:iterator>
					</tbody>
				</table>
			</div>
		 </div>
		 
		 <div id="content-2" style="display:none">
		 	<iframe src="" name="down_frame" id="down_frame" style="display:none"
				frameborder="0" scrolling="auto">
			</iframe> 
				
			<div class="layui-field-box layui-form" id="attachFileDiv">
				<s:iterator value="attachList" id="attachInfo">
					<div class="layui-form-item"><div class="layui-inline "><a href="javascript:void(0)" onclick="util.downloadFile('<%=request.getContextPath()%>/rms/downloadFile','<s:property value='#attachInfo.saveName'/>','<s:property value='#attachInfo.fileName'/>')"><s:property value="#attachInfo.fileName"/></a></div></div>
				</s:iterator>	
			</div>
		 </div>
		 
		
	</div>
</body>
</html>